package com.qian.apiserver.service;

import com.qian.apiserver.dao.MatchRecordDao;
import java.math.BigDecimal;
import java.util.Date;
import com.qian.apiserver.service.IMatchRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import com.yaowk.service.common.BaseRepository;
import com.qian.apiserver.model.MatchRecord;
import com.qian.apiserver.entity.GmMatchRecord;
import com.yaowk.service.common.BaseServiceImpl;
import java.lang.Integer;

public abstract class MatchRecordServiceBase extends BaseServiceImpl<MatchRecord, GmMatchRecord, Integer> implements IMatchRecordService {

	@Autowired
	private MatchRecordDao dao;

	@Override protected MatchRecordDao getDao() {
	return dao;
	}

	@Override
	protected MatchRecord entity2model(GmMatchRecord entity) {
		MatchRecord model = null;
		if(isNotEmpty(entity)){
			model = new MatchRecord();
			model.setId(entity.getId());
			model.setBetting(entity.getBetting());
			model.setWinChip(entity.getWinChip());
			model.setTime(entity.getTime());
			model.setUserId(entity.getUserId());
		}
		return model;
	}

	@Override
	protected GmMatchRecord model2Entity(MatchRecord model) {
		GmMatchRecord entity = null;
		if(isNotEmpty(model)){
			entity = new GmMatchRecord();
			entity.setId(model.getId());
			entity.setBetting(model.getBetting());
			entity.setWinChip(model.getWinChip());
			entity.setTime(model.getTime());
			entity.setUserId(model.getUserId());
		}
		return entity;
	}

	@Override
	protected GmMatchRecord updateParams(MatchRecord model) {
		GmMatchRecord entity = dao.findOne(model.getId());
		if(isNotEmpty(model.getBetting()))
			entity.setBetting(model.getBetting());
		if(isNotEmpty(model.getWinChip()))
			entity.setWinChip(model.getWinChip());
		if(isNotEmpty(model.getTime()))
			entity.setTime(model.getTime());
		if(isNotEmpty(model.getUserId()))
			entity.setUserId(model.getUserId());
		return entity;
	}


}